﻿using LdtDataEngin.Moudle;
using System;
using System.Collections.Generic;
using System.Text;

namespace Ldt.DataEngin.Assemble
{
    /// <summary>
    /// 数据处理流程模块组装类
    /// </summary>
    internal class FlowCombination
    {
        /// <summary>
        /// 数据集合
        /// </summary>
        public  List<Func<IMoudle, IMoudle>> flowModeList = new List<Func<IMoudle, IMoudle>>();

        /// <summary>
        /// 添加数据模块
        /// </summary>
        /// <param name="moudle"></param>
        public void AddMoudle(Func<IMoudle, IMoudle> moudle) 
        {
            flowModeList.Add(moudle);
        }
        /// <summary>
        /// 组装模块，并返回入口模块
        /// </summary>
        /// <returns></returns>
        public IMoudle BuildFlow() 
        {
            flowModeList.Reverse();
            IMoudle moudle = new MoudleEnd();
            foreach (var item in flowModeList)
            {
                moudle=item(moudle);
            }
            return moudle;
        }


    }
}
